
	//根据年份标签查询知识
	function time_search(time) {
		$("#tag_name").val("");
		if(time.substring(0,1)=='空')
			$("#time").val('other');
		else
			$("#time").val(time.substring(0,4));
		$('#tb_departments').bootstrapTable('refreshOptions',{pageNumber:1});
		
	}
	//根据其他标签查询知识
	function tag_search(tag_name) {
		
		$("#time").val("");
		var arr = tag_name.split("(");
		$("#tag_name").val(arr[0]);
		$('#tb_departments').bootstrapTable('refreshOptions',{pageNumber:1});
		
	}
	//获取zTree树选中的节点的ID，将他们拼接成为字符串
	function getReczskIDS() {
		var treeObj = $.fn.zTree.getZTreeObj("treeDemo");
		var nodes = treeObj.getCheckedNodes(true);
		var reczsk_ids = [];//要删除的序号组合
		var reczsk_id;
		if (nodes.length != 0) {
			for (var i = 0; i < nodes.length; i++)
				reczsk_ids.push(nodes[i].id);
			reczsk_id = reczsk_ids.join(",");
		} else
			reczsk_id = "";
		return reczsk_id;
	}

	//更新html页面上的标签部分
	function initTab(taglist) {
		var myTab = $("#myTab");
		var TabContent = $("#myTabContent");
		$("#myTab").empty();
		$("#myTabContent").empty();
		var i;
		var j;
		var addStr = "<li class='active'><a href='#"+taglist[taglist.length-1].tag_id+"' data-toggle='tab'><span class='tabfont'>"
		+ taglist[taglist.length-1].name + "</span></a></li>";
		//var addStr = "";
		for (i = 0; i < taglist.length-1; i++) {
			addStr = addStr
					+ "<li><a href='#"+taglist[i].tag_id+"' data-toggle='tab'>"
					+ taglist[i].name + "</a></li>";
		}
		var tagcontent = "";
		for (i = 0; i < taglist.length-1; i++) {
			tagcontent = tagcontent
					+ "<div class='tab-pane fade' id='"+taglist[i].tag_id+"'><ul class='infotul' id='"+taglist[i].tag_id+"'>";
			for (j = 0; j < taglist[i].list.length; j++) {
				tagcontent = tagcontent + "<li><a  onclick='tag_search(&quot;"
						+ taglist[i].list[j].name
						+ "&quot;)'><span class='text-primary'>"
						+ taglist[i].list[j].name + "</span></a></li>";
			}
			tagcontent = tagcontent + "</ul></div>";
		}
		tagcontent = tagcontent
		+ "<div class='tab-pane fade in active' id='"+taglist[taglist.length-1].tag_id+"'><ul class='infoul' id='"+taglist[taglist.length-1].tag_id+"'>";
		if(taglist[taglist.length-1].list.length ==19 ||taglist[taglist.length-1].list.length ==20){
			for(var i =0;i<taglist[taglist.length-1].list.length;i++){
				tagcontent = tagcontent+"<li><a href='javascript:void(0)' onclick='time_search(&quot;"+taglist[taglist.length-1].list[i].name+ "&quot;)'><span class='text-primary'>"+taglist[taglist.length-1].list[i].name+"</span></a></li>";
			}
		}
		else{
			for(var i =0;i<taglist[taglist.length-1].list.length;i++){
				if(i<=18)
	    			tagcontent = tagcontent+"<li><a href='javascript:void(0)' onclick='time_search(&quot;"+taglist[taglist.length-1].list[i].name+ "&quot;)'><span class='text-primary'>"+taglist[taglist.length-1].list[i].name+"</span></a></li>";
	    		else
	    		{
	    			tagcontent = tagcontent+"<li id='more'><a href='javascript:void(0)'  onclick='addYearTag()'><span class='text-primary'>更多</span></a></li>";
					break;
	    		}
	    			
		}
		}
		tagcontent = tagcontent + "</ul></div>";
		myTab.append(addStr);
		TabContent.append(tagcontent);
	}
	function addYearTag(){
			var TabContent = $("#"+taglist[taglist.length-1].tag_id+" ul");
			var remainContent ="";
			$('#'+taglist[taglist.length-1].tag_id+' #more').remove();
			for(var i =19;i<taglist[taglist.length-1].list.length;i++)
				{
					remainContent = remainContent+"<li id='add'><a href='javascript:void(0)' onclick='time_search(&quot;"+taglist[taglist.length-1].list[i].name+ "&quot;)'><span class='text-primary'>"+taglist[taglist.length-1].list[i].name+"</span></a></li>";
				}
			remainContent = remainContent+"<li  id='sub'><a href='javascript:void(0)' onclick='removeYear()'><span class='text-primary'>收起</span></a></li>";
			TabContent.append(remainContent);
			decorate();
	}
	function removeYear(){
		var TabContent = $("#"+taglist[taglist.length-1].tag_id+" ul");
		var remainContent ="";
		$('#'+taglist[taglist.length-1].tag_id+' #sub').remove();
		$('#'+taglist[taglist.length-1].tag_id+' #add').remove();
		var remainContent ="<li id='more'><a href='javascript:void(0)'  onclick='addYearTag()'><span class='text-primary'>更多</span></a></li>";
		TabContent.append(remainContent);
		decorate();
	}
	
	function down(url,infoid,status,level){
		var userid =$("#userid").val();
		if (userid.length !=0){
			var role =$("#role").val();
			if(role=="vip用户"||role=="知识管理员"||role=="超级知识管理员")
			{
				var url = encodeURI("../information/p_downloadn?filename=" + url+"&infoid="+infoid+"&status="+status);
				window.location.href =url;
			}
			else
			{
				if(level==2) {
					alert("该条知识是vip知识,您不具有下载权限");
					return;
				}
				else
				{
					var result = getJg();
					if(result==0){
						alert("您的积分不足，不能进行下载");
						return;
					}
					else
					{
					var url = encodeURI("../information/p_downloadn?filename=" + url+"&infoid="+infoid+"&status="+status);
					window.location.href =url;
					}
				}
			}
		}
		else{
			var url = encodeURI("../information/p_downloadn?filename=" + url+"&infoid="+infoid+"&status="+status);
			window.location.href =url;
		}
		
	}
	function send(){
		var name=$('#name').val();
		var url=$('#url').val();
		var toemail=$('#toemail').val();
		$.ajax({
			url:"../information/p_sendemail",
			async:false,
			data:encodeURI("filename=" + url+ "&truename=" + name+"&toemail="+toemail),
			success:function(result){
 	            $("#sendEmail").modal("hide");
					if(result==1){
						alert("发送成功,如果收件箱中没有，请到垃圾箱中查找");
				}
				else{
					alert("发送失败,文件可能不存在");
				}
				
			}
		});
	}
	//查看知识详情
	function check(id,keyword) {
		var url= encodeURI("../information/getInfoDetial?info_id="+id+"&keyword="+keyword);
		 window.open(url);
	}
	//给查询标签加样式,在选择一个标签所属的值的同时取消本标签下所选的其他值和其他标签下所选中的值
	 function decorate(){
		 
		 for(var i =0;taglist.length;i++){
			  var tag = taglist[i].tag_id;
			 $("#"+tag+" li").click(function() {
				     var fid = $(this).parent().attr('id');
		    	  	$(this).siblings('li').removeClass('selected');  // 删除其他兄弟元素的样式
			        $(this).addClass('selected'); // 添加当前元素的样式
			         for(var j =0;taglist.length;j++){
			        	if(taglist[j].tag_id != fid)
			        	   $("#"+taglist[j].tag_id+" li").removeClass('selected');
			        } 
			    });
		}      
	} 
	 //查找积分是否允许下载
	 function getJg(){
		   var userid =$("#userid").val();
		   var jg = 0;
			$.ajax({
				url:"../information/getPermitload",
				async:false,
				data:"userid="+userid,
				success:function(result){
					jg= result;
				}
			});
			return jg;
	 }